home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / ifp1s157.zip / PAGE_20.PAS < prev    next >
Pascal/Delphi Source File  |  1993-06-26  |  10KB  |  346 lines

  1. unit page_20;
  2.  
  3. interface
  4.  
  5. uses Crt, Dos, IFPGlobl, IFPComon, IFPExtrn;
  6.  
  7. procedure page20;
  8.  
  9. implementation
  10.  
  11. procedure page20;
  12.  
  13. var
  14.   Regs: registers;
  15.   Handle: word;
  16.   Buffer: array[0..255] of byte;
  17.   S: string;
  18.  
  19.   procedure ShowQEMMinfo(APISeg, APIOfs: word);
  20.     const
  21.       QEMMMemType: array[0..$B] of char = 'm?MHXVRAsFrC';
  22.       QEMMMemAccess: array[0..3] of char = '-+*!';
  23.       QEMMStealth: array[0..1] of char = ' S';
  24.  
  25.     type
  26.       TStealthRec = record
  27.                       StartingSeg: word;
  28.                       ParaSize: word;
  29.                     end;
  30.  
  31.       TStatRec = record
  32.                    ExtraMemType: byte;
  33.                    InitConvMem: longint;
  34.                    InitExtMem: longint;
  35.                    InitExpMem: longint;
  36.                    InitExtraMem: longint;
  37.                    UnAvailConv: longint;
  38.                    UnAvailExt: longint;
  39.                    UnAvailExp: longint;
  40.                    UnAvailExtra1: longint;
  41.                    CodeSize: longint;
  42.                    DataSize: longint;
  43.                    TaskSize: longint;
  44.                    DMASize: longint;
  45.                    MAPSize: longint;
  46.                    HiRAMSize: longint;
  47.                    MappedROMSize: longint;
  48.                    ConvMemSize: longint;
  49.                    ExtMemSize: longint;
  50.                    EMSXMSMemSize: longint;
  51.                    UnAvailExtra2: longint;
  52.                    ConvOverhead: longint;
  53.                  end;
  54.  
  55.     var
  56.       API: longint;
  57.       Regs: registers;
  58.       QEMMVersion: word;
  59.       QEMMStat: TStatRec;
  60.       LineNo: word;
  61.       BufferPos: word;
  62.       StealthBuf: array[1..64] of TStealthRec;
  63.       StealthCount: word;
  64.       StealthStart, StealthSize, StealthSet: word;
  65.       InitMem, CurrentMem: longint;
  66.  
  67.     procedure ShowSize(long: longint);
  68.       begin
  69.       Write(long:8, ' (', (long / 1024):7:1, 'K)');
  70.       end;
  71.  
  72.     begin
  73.     API:=longint(APISeg) shl 16 + APIOfs;
  74.     with Regs do
  75.       begin
  76.       Caption2('Memory Manager');
  77.       Write('QEMM');
  78.       Caption3('Version');
  79.       AH:=3;
  80.       LongCall(API, Regs);
  81.       Write(unBCD(BH), decimal, AddZero(unBCD(BL)));
  82.       QEMMVersion:=BX;
  83.       Caption3('Mode');
  84.       AH:=0;
  85.       LongCall(API, Regs);
  86.       if AL and 2 = 2 then
  87.         begin
  88.         Write('Auto');
  89.         Caption3('Current Setting');
  90.         end;
  91.       if AL and 1 = 1 then
  92.         Writeln('OFF')
  93.       else
  94.         Writeln('ON');
  95.       Caption3('API Entry');
  96.       SegOfs(APISeg, APIOfs);
  97.       if Hi(QEMMVersion) >= 6 then
  98.         begin
  99.         Caption3('Stealth');
  100.         AH:=$1E;
  101.         AL:=0;
  102.         LongCall(API, Regs);
  103.         case CL of
  104.           0:   Writeln('OFF');
  105.           $46: Write('Frame');
  106.           $4D: Write('Map')
  107.         else
  108.           Writeln('Unknown value - ', Hex(CL, 2), 'h');
  109.         end;
  110.         if (CL = $46) or (CL = $4D) then
  111.           begin
  112.           Caption3('Number of ROMs Stealthed');
  113.           AH:=$1E;
  114.           AL:=1;
  115.           LongCall(API, Regs);
  116.           if NoCarry(Regs) then
  117.             Writeln(BX)
  118.           else
  119.             Writeln('Error');
  120.           end;
  121.         end;
  122.       AH:=$17;
  123.       ES:=Seg(QEMMStat);
  124.       DI:=Ofs(QEMMStat);
  125.       QEMMStat.ConvOverhead:=0;
  126.       LongCall(API, Regs);
  127.       if not NoCarry(Regs) then
  128.         begin
  129.         Writeln('Unable to retrieve QEMM Statistics!');
  130.         Writeln('This information may only be available with 5.00 or newer.');
  131.         end
  132.       else
  133.         with QEMMStat do
  134.           begin
  135.           Writeln;
  136.           Caption1('---Initial Memory Settings---');
  137.           Writeln;
  138.           Caption3('Conventional');
  139.           ShowSize(InitConvMem);
  140.           Caption3('  Extended');
  141.           ShowSize(InitExtMem);
  142.           Writeln;
  143.           Caption3('    Expanded');
  144.           ShowSize(InitExpMem);
  145.           if ExtraMemType = 1 then
  146.             Caption3('    Shadow')
  147.           else
  148.             Caption3(' Top/Other');
  149.           ShowSize(InitExtraMem);
  150.           Writeln;
  151.           Caption3('       Total');
  152.           InitMem:=InitConvMem + InitExtMem + InitExtraMem;
  153.           ShowSize(InitMem);
  154.           Writeln;
  155.           Writeln;
  156.           Caption1('---Current Memory Settings---');
  157.           Writeln;
  158.           Caption3('Conventional');
  159.           ShowSize(ConvMemSize);
  160.           Caption3('  Extended');
  161.           ShowSize(ExtMemSize);
  162.           Writeln;
  163.           Caption3('EMS/XMS Pool');
  164.           ShowSize(EMSXMSMemSize);
  165.           Caption3('  High RAM');
  166.           ShowSize(HiRAMSize);
  167.           Writeln;
  168.           Caption3('  Mapped ROM');
  169.           Showsize(MappedROMSize);
  170.           Caption3('DMA Buffer');
  171.           ShowSize(DMASize);
  172.           Writeln;
  173.           Caption3('       TASKS');
  174.           ShowSize(TaskSize);
  175.           Caption3('      MAPS');
  176.           ShowSize(MAPSize);
  177.           Writeln;
  178.           Caption3('   QEMM code');
  179.           ShowSize(CodeSize);
  180.           Caption3(' QEMM data');
  181.           ShowSize(DataSize);
  182.           Writeln;
  183.           CurrentMem:=CodeSize + DataSize + TaskSize + DMASize + MAPSize +
  184.                       HiRAMSize + MappedROMSize + ConvMemSize + ExtMemSize +
  185.                       EMSXMSMemSize;
  186.           Caption3('       Total');
  187.           Showsize(CurrentMem);
  188.           Caption3('Unassigned');
  189.           ShowSize(InitMem - CurrentMem);
  190.           Writeln;
  191.           Caption3('                 Conventional Memory Overhead');
  192.           ShowSize(ConvOverhead);
  193.           Writeln;
  194.           Writeln;
  195.           Caption1('---Unavailable Memory Settings---');
  196.           Writeln;
  197.           Caption3('Conventional');
  198.           ShowSize(UnAvailConv);
  199.           Caption3('  Extended');
  200.           ShowSize(UnAvailExt);
  201.           Writeln;
  202.           Caption3('    Expanded');
  203.           ShowSize(UnAvailExp);
  204.           Caption3('Shadow/Top');
  205.           ShowSize(UnAvailExtra1 + UnAvailExtra2);
  206.           Writeln;
  207.           end;
  208.       AH:=$11;
  209.       AL:=0;
  210.       ES:=Seg(Buffer);
  211.       DI:=Ofs(Buffer);
  212.       LongCall(API, regs);
  213.       if not NoCarry(Regs) then
  214.         Writeln('Unable to get Memory type map.')
  215.       else
  216.         begin
  217.         Pause1;
  218.         if EndIt then
  219.           Exit;
  220.         ClrScr;
  221.         TextColor(LightGray);
  222.         Write('                 Memory Type/Memory Access/Stealth Info');
  223.         for LineNo:=0 to $0F do
  224.           begin
  225.           GotoXY(1, 17 - LineNo);
  226.           Write(Hex(LineNo, 1), 'x00');
  227.           end;
  228.         GotoXY(1, 18);
  229.         Writeln('      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F');
  230.         Writeln('m=mappable RAM, M=Mapped ROM, H=High RAM, X=eXcluded, V=Video, R=ROM');
  231.         Writeln('A=Adapter ROM, s=split ROM, F=EMS Page Frame, r=RAMmable, C=Conventional');
  232.         Write('-=Not Accessed, +=Read, *=Written, !=Read/Written, S=Stealth ROM');
  233.         TextColor(LightCyan);
  234.         Window(Lo(WindMin) + 6, Hi(WindMin) + 2, twidth, Hi(WindMin) + 18);
  235.         if EMSOK then
  236.           begin
  237.           AH:=$41;
  238.           Intr($67, regs);
  239.           if AH = 0 then
  240.             for BufferPos:=BX div 256 to (BX div 256) + 15 do
  241.               Buffer[BufferPos]:=9;
  242.           end;
  243.         for BufferPos:=0 to 255 do
  244.           begin
  245.           GotoXY(4 * (BufferPos mod 16) + 1, 16 - (BufferPos div 16));
  246.           if Buffer[BufferPos] > $B then
  247.             Write('?')
  248.           else
  249.             Write(QEMMMemType[Buffer[BufferPos]]);
  250.           end;
  251.         AH:=$16;
  252.         AL:=0;
  253.         ES:=Seg(Buffer);
  254.         DI:=Ofs(Buffer);
  255.         LongCall(API, Regs);
  256.         if not NoCarry(Regs) then
  257.           FillChar(Buffer, SizeOf(Buffer), #255);
  258.         for BufferPos:=0 to 255 do
  259.           begin
  260.           GotoXY(4 * (BufferPos mod 16) + 2, 16 - (BufferPos div 16));
  261.           if Buffer[BufferPos] > 3 then
  262.             Write('?')
  263.           else
  264.             Write(QEMMMemAccess[Buffer[BufferPos]]);
  265.           end;
  266.         FillChar(Buffer, SizeOf(Buffer), 0);
  267.         AH:=$1E;
  268.         AL:=1;
  269.         LongCall(API, Regs);
  270.         if (BX > 0) and (BX < 65) then
  271.           begin
  272.           AH:=$1E;
  273.           AL:=2;
  274.           ES:=Seg(StealthBuf);
  275.           DI:=Ofs(StealthBuf);
  276.           LongCall(API, Regs);
  277.           if NoCarry(Regs) then
  278.             for StealthCount:=1 to BX do
  279.               begin
  280.               StealthSize:=StealthBuf[StealthCount].ParaSize div 256;
  281.               StealthStart:=StealthBuf[StealthCount].StartingSeg div 256;
  282.               for StealthSet:=StealthStart to StealthStart + StealthSize do
  283.                 Buffer[StealthSet]:=1;
  284.               end;
  285.           end;
  286.         for BufferPos:=0 to 255 do
  287.           begin
  288.           GotoXY(4 * (BufferPos mod 16) + 3, 16 - (BufferPos div 16));
  289.           if Buffer[BufferPos] > 1 then
  290.             Write('?')
  291.           else
  292.             Write(QEMMStealth[Buffer[BufferPos]]);
  293.           end;
  294.         end;
  295.       end;
  296.     end;
  297.  
  298. begin
  299. with Regs do
  300.   begin
  301.   S:='QEMM386$'#0;
  302.   AX:=$3D00;
  303.   DS:=Seg(S);
  304.   DX:=Ofs(S) + 1;
  305.   MsDos(Regs);
  306.   if not NoCarry(Regs) then
  307.     Writeln('Currently, only QEMM 4.23 or newer is supported. It was not found.')
  308.   else
  309.     begin
  310.     Handle:=AX;
  311.     AX:=$4402;
  312.     BX:=Handle;
  313.     CX:=4;
  314.     DS:=Seg(Buffer);
  315.     DX:=Ofs(Buffer);
  316.     MsDos(Regs);
  317.     if not NoCarry(Regs) then
  318.       if EMSOK then
  319.         begin
  320.         AH:=$3F;
  321.         CX:=$5145; {QE}
  322.         DX:=$4D4D; {MM}
  323.         Intr($67, regs);
  324.         if AH = 0 then
  325.           ShowQEMMinfo(ES, DI)
  326.         else
  327.           begin
  328.           Writeln('QEMM possibly found, but both the IOCTL and special EMS calls failed.');
  329.           Writeln('INFOPLUS is unable to find the API entry point.');
  330.           end;
  331.         end
  332.       else
  333.         begin
  334.         Writeln('QEMM possibly found, but the IOCTL call failed. No EMS memory is being');
  335.         Writeln('provided, preventing a secondary attempt to find the API entry point.');
  336.         end
  337.     else
  338.       ShowQEMMinfo(word(Buffer[3]) shl 8 + Buffer[2],
  339.                   word(Buffer[1]) shl 8 + Buffer[0]);
  340.     AH:=$3E;
  341.     BX:=Handle;
  342.     MsDos(Regs);
  343.     end;
  344.   end;
  345. end;
  346. end.